import { Types } from './types.d'
import { message } from 'antd'

const defaultState = {
  queryList: [],
  tableStatus: ''
}

export default (state = defaultState, action:any) => {
  switch(action.type) {
    case Types.FETCH_QUERY_LIST:
      message.success('请求数据成功')
    return {...state,queryList: action.payload, };

    case Types.FETCH_ADD_ITEM:
      message.success('添加成功')
    return {...state, tableStatus: 'add'}

    case Types.FETCH_UPDATE_ITEM:
      message.success('更新数据成功')
    return {...state,  tableStatus: 'update'}

    case Types.FETCH_DELTE_ITEM:
      message.success('删除成功')
    return {...state, tableStatus: 'delete'}

    case Types.UPDATE_TABLE_STATUS:
    return {...state, tableStatus: ''}

    default:
    return {...state}
  }
}
